﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace Com
{
    public class MysqlSqlite
    {
        public static string GetDateTime()
        {
            string now = string.Empty;
            switch (ConfigurationManager.AppSettings["DAL"].ToLower())
            {
                case "mysql":
                    now = "now()";
                    break;
                case "sqlite":
                    now = "datetime(CURRENT_TIMESTAMP,'localtime')";
                    break;
                case "sqlserver":
                    now = "GETDATE()";
                    break;
            }
            return now;
        }

        public static string Ntianqian(int day)
        {
            string result = string.Empty;
            switch (ConfigurationManager.AppSettings["DAL"].ToLower())
            {
                case "mysql":
                    result = "TO_DAYS(NOW())-TO_DAYS(addtime)>" + day + "";
                    break;
                case "sqlite":
                    result = "date('now', '-"+ day + " day') >= date(addtime)";
                    break;
                case "sqlserver":
                    result = "datediff(day,[addtime],getdate()) > " + day;
                    break;
            }
            return result;
        }
    }
}
